// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE in the project root for license information.

//
// Office UI Fabric
// --------------------------------------------------
// Dropdown styles


.ms-Dropdown {
  @include ms-font-m;
  @include ms-u-normalize;
  margin-bottom: 10px;
  position: relative;
  outline: 0;

  &:hover,
  &:focus,
  &:active {
    .ms-Dropdown-title,
    .ms-Dropdown-caretDown {
      color: $ms-color-black;
    }
  }

  &:hover,
  &:active {
    .ms-Dropdown-title {
      border-color: $ms-color-neutralSecondaryAlt; 
    }
  }

  &:focus {
    .ms-Dropdown-title {
      border-color: $ms-color-themePrimary;
    }
  }
}

//== State: A disabled dropdown
.ms-Dropdown.is-disabled {
  .ms-Dropdown-title {
    background-color: $ms-color-neutralLighter;
    border-color: $ms-color-neutralLighter;
    color: $ms-color-neutralTertiary;
    cursor: default;
  }
  
  .ms-Dropdown-caretDown {
    color: $ms-color-neutralTertiary;
  }
}

// When the dropdown is opened
// Note: .ms-Dropdown--open is deprecated and will be removed in a future version. 
// Use .is-open for an open dropdown.
.ms-Dropdown.ms-Dropdown--open .ms-Dropdown-items,
.ms-Dropdown.is-open .ms-Dropdown-items {
  display: block;
  position: fixed;
}

// Hide the original dropdown
.ms-Dropdown-select {
  display: none;
}

.ms-Dropdown-caretDown {
  color: $ms-color-neutralSecondary;
  font-size: $ms-font-size-l;
  position: absolute;
  right: 9px;
  bottom: 5px;
  z-index: 1;
  pointer-events: none;
}

// Style the new, replacement component
.ms-Dropdown-title {
  @include ms-u-normalize;
  background: $ms-color-white;
  border: 1px solid $ms-color-neutralTertiaryAlt;
  cursor: pointer;
  display: block;
  height: 32px;
  line-height: 30px;
  padding: 0 32px 0 10px;
  position: relative;
  overflow: hidden;
}

// Container for the dropdown items, displayed as a panel on small screens.
.ms-Dropdown-items {
  @include ms-u-normalize;
  @include drop-shadow;
  background-color: $ms-color-white;
  display: none;
  list-style-type: none;
  position: absolute;
  width: 100%;
  max-width: 268px;
  z-index: ($ms-zIndex-Dropdown + $ms-zIndex-back);
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: scroll;

  &:before {
    content: '';
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid $ms-color-neutralLight;
  }
}

.ms-Dropdown-item {
  box-sizing: border-box;
  cursor: pointer;
  display: block;
  height: 40px;
  line-height: 38px;
  padding: 0 10px;
  position: relative;
  border: 1px solid transparent;
  white-space: nowrap;

  // Shorten the first and last items to maintain baseline alignment.
  &:first-child, 
  &:last-child {
    height: 39px;
  }

  &:hover {
    background-color: $ms-color-neutralLight;
    color: $ms-color-black;
    outline: 1px solid transparent;
  }

  &:active {
    background-color: $ms-color-neutralLight;
    border-color: $ms-color-themePrimary;
    color: $ms-color-black;
  }

  &.is-disabled {
    background: $ms-color-white;
    color: $ms-color-neutralTertiary;
    cursor: default;
    line-height: 40px;
  }
}

//== State: A selected dropdown item
// Note: .ms-Dropdown-item--selected is deprecated and will be removed in a future version.
// Use .is-selected instead.
.ms-Dropdown-item.is-selected,
.ms-Dropdown-item.ms-Dropdown-item--selected {
  background-color: $ms-color-themeLight;
  color: $ms-color-black;
  line-height: 40px;

  &:hover {
    background-color: $ms-color-themeLight;
  }
}


@media (min-width: $ms-screen-md-min) {
  // On larger screens, display as a traditional dropdown.
  .ms-Dropdown-items {
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    max-width: 100%;
  }

  .ms-Dropdown.ms-Dropdown--open .ms-Dropdown-items,
  .ms-Dropdown.is-open .ms-Dropdown-items {
    position: absolute;
  }
}
